{include file='comdir/head.html'}
<body>
<div class="content">
	<div class="animated fadeInDown">
		<div class="pos"><a href="#" onClick="javascript :history.back(-1);">返回上一页</a></div>
		<div class="btn-box">
			<button class="btn btn-sm btn-success articleadd">添加</button>
			<button class="btn btn-sm btn-bgcolor1" onClick='editAll("recommendflag",1)'>推荐</button>
			<button class="btn btn-sm btn-bgcolor1focus" onClick='editAll("recommendflag",0)'>关闭推荐</button>
			<button class="btn btn-sm btn-bgcolor2" onClick='editAll("headflag",1)'>置顶</button>
			<button class="btn btn-sm btn-bgcolor2focus" onClick='editAll("headflag",0)'>关闭置顶</button>
			<button class="btn btn-sm btn-bgcolor3" onClick='editAll("verify",1)'>审核</button>
			<button class="btn btn-sm btn-bgcolor3focus" onClick='editAll("verify",0)'>关闭审核</button>
		</div>
		<div class="searchBox">
            <form class="form-inline" action="javascript:void(0)">
				<span>
                站点栏目：
                <select class="form-control colid"  name="colid">
                    <option value="-1">全部</option>
					{$columnselected}
					</select>
                </span>
                <span>
                 标题：<input type="text" class="form-control title " name="title" value="">
                </span>
                <span><input type="button" class="form-control btn-blue article_searh" value="搜索"></span>
				<select name="sortvalue" class='form-control sortvalue'>
					<option {if $sortvalue=='addtime_1'}selected{/if} value="addtime_1">创建时间↓</option>
					<option {if $sortvalue=='addtime_2'}selected{/if} value="addtime_2">创建时间↑</option>
					<option {if $sortvalue=='seq_1'}selected{/if} value="seq_1">排序值↓</option>
					<option {if $sortvalue=='seq_2'}selected{/if} value="seq_2">排序值↑</option>
				</select>
            </form>
        </div>
		<div class="table_list_wrap">
			<div class="table-responsive">
				<table class="table table-bordered table-hover">
					<thead>
						<tr>
							<th>
								<div class="checkbox checkbox-inline">
									<input type="checkbox" id="checkall"  name="checkall" class="chekall" onchange="checkbox_all()">
									<label for="checkall"></label>
								</div>
							</th>
							<th style="width:40px;">ID</th>
							<th style="width:50px;">图片</th>
							<th>标题</th>
							<th style="width:30px;">颜色</th>
							<th>栏目</th>
							<th>站点</th>
							
							<th style="width:60px;">点击量</th>
							<th style="width:100px;">新建时间</th>
							<th style="width:120px;">排序</th>
							<th style="width:100px;">荐|顶|审</th>
							<th style="width:100px;">操作</th>
						</tr>
					</thead>
					<tbody class="listtbody">
						{foreach from=$list item=vo}
							<tr class="infoid_{$vo.infoid}">
								<td>
									<div class="checkbox checkbox-inline">
										<input type="checkbox" id="{$vo.infoid}" class="checkone" name="checkone" value="{$vo.infoid}">
										<label for="{$vo.infoid}"></label>
									</div>
								</td>
								<td>{$vo.infoid}</td>
								<td>{if $vo.defaultpicurl != ''}<img src="{$getConfig.upload_http}{$vo.defaultpicurl}" style="max-width:50px;max-height:30px;">{/if}</td>
								<td>{$vo.title}</td>
								<td>
									<div class="titilecolor" style="background:{$vo.titilecolor};"></div>
								</td>
								<td>{$vo.columnname}</td>
								<td>{$vo.sitesname}</td>
								
								<td>{$vo.hits}</td>
								
								<td>{$vo.addtime|date_format:'%Y-%m-%d %H:%M:%S'}</td>
								<td><input type="text" class="seq form-control" data-infoid='{$vo.infoid}' data-orderid='{$vo.seq}' value="{$vo.seq}"></td>
								<td>
									<span  data-infoid="{$vo.infoid}" {if $vo.recommendflag==1} class='btn-bgcolcor btn-bgcolor1 recommendflag1' {else} class='btn-bgcolcor btn-bgcolor1focus recommendflag0' {/if} onClick="recommendflag({$vo.recommendflag},this)">荐</span>
									<span  data-infoid="{$vo.infoid}" {if $vo.headflag==1} class='btn-bgcolcor btn-bgcolor2 headflag1'  {else} class='btn-bgcolcor btn-bgcolor2focus headflag0'      {/if} onClick="headflag({$vo.headflag},this)">顶</span>
									<span  data-infoid="{$vo.infoid}" {if $vo.verify==1} class='btn-bgcolcor btn-bgcolor3 verify1'  {else} class='btn-bgcolcor btn-bgcolor3focus verify0'      {/if} onClick="verify({$vo.verify},this)">审</span>
								</td>
								<td>
									<input type="button" onclick="edit({$vo.infoid})" class="btn btn-xs btn-warning" value="编辑">
									<input type="button" onclick="del({$vo.infoid})" class="btn btn-xs btn-danger" value="回收">
								</td>
							</tr>
						{/foreach}
					</tbody>
				</table>
			</div>
		</div>
	</div>
	<div class="page-box">
			<div class="page">
				{if $list}
					{$pageshow}
				{/if}
			</div>
		</div>
</div>
<script type="text/javascript">
	var _URL='{$_URL}';
	{literal}
		$(function(){
			//更新排序
			$('.seq').blur(function(){
				var url=_URL+"Article/edit";
				var orderid=$(this).val();
				var ifnoid=$(this).attr('data-infoid');
				var orderid_old=$(this).attr('data-orderid');
				if(orderid==orderid_old){
					return false;
				}
				_ajaxs.post(url,"seqedit=1&orderid="+orderid+"&infoid="+ifnoid,function(data){
					layer.msg(data.msg,{icon: 1}, function(){});
				});
			})
			//文章搜索
			$('.article_searh').click(function(){
				ajaxpage(false);
			})
			//排序
			$('.sortvalue').change(function(){
				ajaxpage(false);
			})
			//添加文章
			$('.articleadd').click(function(){
				window.location.href=_URL+"Article/add";
			})
		})
		/*全选*/
		function checkbox_all(){
			_checkboxAll.all_move('checkone','checkall');
		}
		//文章编辑
		function edit(id){
			window.location.href=_URL+"Article/edit?list=1&infoid="+id;
		}
		//批量跟新
		function editAll(type,value){
			var valuestr=_checkboxAll.value('checkone',false,',');
			if(!valuestr){
				  layer.msg('未选中文章',{icon: 1}, function(){});
				  return false;
			 }
			 var url=_URL+"Article/edit";
			_ajaxs.post(url,"editAll_ajaxs=1&type="+type+'&value='+value+"&infostr="+valuestr,function(data){
				layer.msg(data.msg,{icon: 1}, function(){
					if(data.status){
						$('.chekall').prop('checked',false);
						var page=$('.current').html();
						ajaxpage(page);
					}
				});
			});
		}
		//编辑推荐
		var recommendflagstatus=true;
		function recommendflag(value,objthis){
			var obj=$(objthis);
			var infoid=obj.attr('data-infoid');
			var recommendflag=0;
			if(value==0){recommendflag=1}
			var url=_URL+"Article/edit";
			if(recommendflagstatus===false){return false;}
			recommendflagstatus=false;
			_ajaxs.post(url,"recommendflag_ajaxs=1&recommendflag="+recommendflag+'&infoid='+infoid,function(data){
				layer.msg(data.msg,{icon: 1}, function(){
					if(data.status){
						if(recommendflag==1){obj.addClass('btn-bgcolor');}
						if(recommendflag==0){obj.addClass('btn-bgcolor1focus');}
					}
					recommendflagstatus=true;
				});
			});
		}
		//编辑推荐
		var headflagstatus=true;
		function headflag(value,objthis){
			var obj=$(objthis);
			var infoid=obj.attr('data-infoid');
			var headflag=0;
			if(value==0){headflag=1}
			var url=_URL+"Article/edit";
			if(headflagstatus===false){return false;}
			headflagstatus=false;
			_ajaxs.post(url,"headflag_ajaxs=1&headflag="+headflag+'&infoid='+infoid,function(data){
				layer.msg(data.msg,{icon: 1}, function(){
					if(data.status){
						if(headflag==1){obj.addClass('btn-bgcolor2');}
						if(headflag==0){obj.addClass('btn-bgcolor2focus');}
					}
					headflagstatus=true;
				});
			});
		}
		//编辑推荐
		var verifystatus=true;
		function verify(value,objthis){
			var obj=$(objthis);
			var infoid=obj.attr('data-infoid');
			var verify=0;
			if(value==0){verify=1}
			var url=_URL+"Article/edit";
			if(verifystatus===false){return false;}
			verifystatus=false;
			_ajaxs.post(url,"verify_ajaxs=1&verify="+verify+'&infoid='+infoid,function(data){
				layer.msg(data.msg,{icon: 1}, function(){
					if(data.status){
						if(verify==1){obj.addClass('btn-bgcolor3');}
						if(verify==0){obj.addClass('btn-bgcolor3focus');}
					}
				});
				verifystatus=true;
			});
		}
		//删除到回收站
		function del(id){
			var url=_URL+"Article/del";
			var del_all=layer.confirm('确认要删除吗！', {btn: ['确认','取消'],'title':'站点'},function(){
				_ajaxs.post(url,'recycle=1&infoid='+id,function(data){
					layer.msg(data.msg,{icon: 1}, function(){});
					if(data.status){
						$('.infoid_'+id).remove();
					}
					layer.close(index);
				})
			});
		}
		function ajaxpage(page){
			url='';
			url+=_sousuo.value('.title','title');
			url+=_sousuo.selected('.colid','colid',-1);
			url+=_sousuo.selected('.sortvalue','sortvalue',-1);
			if(page){
				url+="page="+page;
			}else{
				if(url!=''){
					url=url.substring(0,url.length-1);
				}
			}
			_ajaxs.post(_URL+"Article/lists",url,function _return(data){
				$('.listtbody').html('');
				$('.listtbody').html(data.data.list);
				if(data.data.pageshow){
					$('.page').html(data.data.pageshow);
				}else{
					$('.page').html('');
				}
			},'json')
		}
	{/literal}
</script>
</body>
</html>